<template>
  <div class="nodeTableWrapper">
    <div class="title">节点样式</div>
    <el-table
      :data="$store.state.knowledgeMap.nodeConfig"
      max-height="236"
      :cell-style="{ borderColor: '#F2F2F2', padding: '4px' }"
      style="width: 100%"
      class="config-table"
    >
      <el-table-column type="selection" width="50" align="center">
      </el-table-column>
      <el-table-column
        :resizable="false"
        :show-overflow-tooltip="true"
        align="left"
        prop="attribute"
        label="选项"
        width="100"
      >
      </el-table-column>
      <el-table-column
        :resizable="false"
        :show-overflow-tooltip="true"
        align="left"
        prop="attribute"
        label="颜色"
        width="130"
      >
        <template slot-scope="scope">
          <el-color-picker
            v-model="scope.row.color"
            size="mini"
            @change="changeColor(scope.row)"
          ></el-color-picker>
        </template>
      </el-table-column>
      <el-table-column
        :resizable="false"
        :show-overflow-tooltip="true"
        align="left"
        prop="radius"
        label="半径"
        width="100"
      >
        <template slot-scope="scope">
          <el-input
            v-model="scope.row.radius"
            placeholder=""
            @change="changeSize(scope.row)"
          ></el-input>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name: 'node-table',
  components: {},
  props: {},
  data() {
    return {
      // tableData: [{
      //     attribute: '所选连线',
      //     color: "#F4D03F",
      //     radius: "20",
      //     // ontology_id: "qwr11231",
      //   }, {
      //     attribute: '地区',
      //     color: "#A2D9CE",
      //     radius: "20",
      //   }, {
      //     attribute: '学校',
      //     color: "#2471A3",
      //     radius: "20",
      //   },
      //   {
      //     attribute: '人物',
      //     color: "#EC7063",
      //     radius: "20",
      //   },
      //   {
      //     attribute: '医院',
      //     color: "#2E4053",
      //     radius: "20",
      //   }
      // ],
    }
  },
  methods: {
    changeColor(e) {
      this.$store.commit('knowledgeMap/change_targetNode', e)
      this.$eventBus.$emit('updateNodeColor')
    },
    changeSize(e) {
      this.$store.commit('knowledgeMap/change_targetNode', e)
      this.$eventBus.$emit('updateNodeSize')
    },
  },
  watch: {
    '$store.state.knowledgeMap.nodeConfig': {
      handler: function (newVal, oldVal) {},
      deep: true,
    },
  },
}
</script>

<style lang="scss" scoped>
// 颜色选择器的样式
/deep/ .el-table .cell.el-tooltip {
  padding-left: 6px;
}

/deep/ .el-color-picker__trigger {
  padding-left: 0;
  border: none;
  width: 16px;
  height: 16px;
}

/deep/ .el-color-picker__icon {
  display: none;
}

/deep/ .el-color-picker__color {
  width: 16px;
  height: 16px;
  border: none;
}

/deep/ .el-color-picker__color-inner {
  border-radius: 50%;
  border: none;
}
.nodeTableWrapper {
  .title {
    text-align: left;
    height: 21px;
    font-size: 16px;
    color: #333333;
    line-height: 21px;
  }

  .footWrapper {
    display: flex;
    margin-top: 10px;
    justify-content: space-between;

    div:nth-of-type(1) {
      height: 16px;
      font-size: 12px;
      color: #999999;
      line-height: 16px;
    }
  }
  .config-table {
    /deep/ .cell {
      text-align: center;
    }
    /deep/ .el-input__inner {
      text-align: center;
    }
  }
}
</style>
